package com.qf.day03.loop;

import java.util.Scanner;

/*
用户输入任意一个整数，求各位数字之和。
 */
public class RanderNumSum {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int sum = 0;
        System.out.println("请输入一个整数");
        int num = scanner.nextInt();
        for (; ; ) {
            sum += num % 10;
            num /= 10;
            if (num == 0) {
                break;
            }

        }
        System.out.println(sum);
    }
}
